local sk__ganglie = fk.CreateSkill {

  name = "sk__ganglie",

  tags = {},

}



sk__ganglie:addEffect(fk.EventPhaseStart, {
  name = "sk__ganglie",
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(sk__ganglie.name) then
      return player.phase == Player.Play
    end
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, sk__ganglie.name)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:loseHp(target, 1, sk__ganglie.name)
  end,
})
sk__ganglie:addEffect(fk.TurnEnd, {
  name = "sk__ganglie",
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(sk__ganglie.name) then
      return #player.room.logic:getActualDamageEvents(1, function(e)
        local damage = e.data
        return damage.from and damage.from == player
      end, Player.HistoryTurn) > 0
    end
  end,
  on_cost = function(self, event, target, player, data)
    return true
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local n = 0
    room.logic:getActualDamageEvents(1, function(e)
      local damage = e.data
      if damage.from and damage.from == player then
        n = n + damage.damage
      end
      return false
    end, Player.HistoryTurn)
    player:drawCards(n, sk__ganglie.name)
  end,
})

return sk__ganglie
